-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Properly check that an expression might be the one returned #15115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I assume this also fixes #14927, right? I also commented in #14950 (comment) (PR that fixes the same issue) that it seemed odd to me that we're even processing expressions in these positions and that |
639e64d
to
d54ed67
Compare
I had missed #14927, this fixes it indeed, and I've added the test case. I was going to first investigate fixing |
8f896fc
to
76ecbef
Compare
The `TyCtxt::hir_get_fn_id_for_return_block()` function was too broad, as it will return positively even when given part of an expression that can be used as a return value. A new `potential_return_of_enclosing_body()` utility function has been made to represent the fact that an expression might be directly returned from its enclosing body.
76ecbef
to
89f7a43
Compare
Thank you! |
As this introduces a complete new clippy_utils function, I will also rather revert the extension on the beta branch, than backporting this. |
The
TyCtxt::hir_get_fn_id_for_return_block()
function was too broad, as it will return positively even when given part of an expression that can be used as a return value. A newpotential_return_of_enclosing_body()
utility function has been made to represent the fact that an expression might be directly returned from its enclosing body.changelog: [
return_and_then
]: prevent false positives in case of a partially used expressionFixes #15111
Fixes #14927
Summary Notes
Managed by
@rustbot
—see help for details